﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace D3Sparrow.Common.Utilities
{
    public static class DateTimeTool
    {
        [DllImport("kernel32")]
        public static extern void GetSystemTimeAsFileTime(out FILETIME lpSystemTimeAsFileTime);


        public static ulong GetTimeMs()
        {
            ulong time;

            FILETIME fileTime = new FILETIME();

            // get time
            GetSystemTimeAsFileTime(out fileTime);

            time = (ulong)fileTime.dwHighDateTime;
            time = time << 32;

            time += (ulong)fileTime.dwLowDateTime;

            // adjust to 1970
            time -= 116444736000000000;

        // convert to milliseconds
            return time / 10000;
           }
    }
}
